<script setup>
import { List } from "echarts";
import { onMounted, ref, watch } from "vue";
import { getChatMenuList } from "../../services/chat";
const props = defineProps({
  modelValue: Boolean,
});
watch(props.modelValue, (newval, oldval) => {
  if (newval) {
    f_getChatMenuList();
  }
});
const chatMenuList = ref([]);
const f_getChatMenuList = function () {
  getChatMenuList({})
    .then((res) => {
      chatMenuList.value = res.data.map((i) => ({
        text: i.chatMenuName,
        value: i.id,
      }));
    })
    .catch((error) => {});
};
const emit = defineEmits();
const onConfirm = ({ selectedValues }) => {
  emit("update:modelValue", false);
  emit("refreshChatContent", selectedValues[0]);
};
const onCancel = () => {
  emit("update:modelValue", false);
};
onMounted(() => {
  f_getChatMenuList();
});
</script>
<template>
  <div>
    <!-- 底部弹出 -->
    <van-popup
      round
      v-model:show="props.modelValue"
      @close="emit('update:modelValue', false)"
      position="bottom"
    >
      <van-picker
        title="历史菜单"
        :columns="chatMenuList"
        @confirm="onConfirm"
        @cancel="emit('update:modelValue', false)"
      />
    </van-popup>
  </div>
</template>

<style lang="less" scoped></style>
